<template>

<!--  <el-row>
    <bread-crumb>
      <template #one>交易数据管理</template>
      <template #two>交易数据管理</template>
    </bread-crumb>
  </el-row>
  <el-card shadow="always" style="margin: 20px;">
    <el-row class="header">
      <search-bar
          :add-text = searchBarText.addText
          :search-text= searchBarText.searchText
          :placeholder-context= searchBarText.placeholderContext
          @init-jy-info="initInfo"
          @handleDialogJyValue="handleDialogJyValue"
      >
      </search-bar>
      <one-table
          :table-data="tableData"
          :options-info="JyInfo"
          @handleDialogJyValue="handleDialogJyValue"
          @delJyInfo="delJyInfo"
      >
      </one-table>
      <paging :queryForm="queryForm"
              @my-size-change="handleSizeChange"
              @my-current-change="handleCurrentChange">
      </paging>
    </el-row>
  </el-card>
  <dialog-jy
      v-model="dialogVisible"
      v-if="dialogVisible"
      :dialog-jy-table-value="dialogJyTableValue"
      :dialog-jy-title="dialogJyTitle"
      :queryForm="queryForm"
      @handleConfirm="handleConfirm"
  >
  </dialog-jy>-->
  <same>
    <template #head>
      <HeadFour :active-index="activeIndex"></HeadFour>
    </template>
  </same>
</template>

<script setup>
import HeadFour from "@/components/header/headFour.vue";
const activeIndex = '/jysj'

/*import HeadFour from "../../components/header/headFour.vue";
import Paging from "../../components/pagination/paging.vue";
import SearchBar from "../../components/searchBar.vue";
import OneTable from "../../components/table/oneTable.vue";
import BreadCrumb from "../../components/commons/breadCrumb.vue";
import {ref} from "vue";
import {
  addJyInfo,
  deleteJyInfo,
  editJyInfo,
  upJyInfo,
} from "../../api/axiosApi/fourPart.js";
import {ElMessage, ElMessageBox, ElNotification} from "element-plus";
import {isNull} from "../../api/filters.js";
import {JyInfo} from "../../api/options/fourPart/JyInfo.js";
import DialogJy from "../../components/dialog/four/dialogJy.vue";

const activeIndex = '/jysj'
const queryForm = ref({
  query: '',
  pageNum: 1,
  pageSize: 1,
  totalSize: 0
})
const tableData = ref([])
const dialogVisible = ref(false)
const dialogJyTitle = ref('')
const dialogJyTableValue = ref({})
const searchBarText = ref({
  addText : "新增交易数据",
  searchText : "搜索交易数据",
  placeholderContext: "请输入内容"
})
const initInfo = async ()=> {
  try {
    let res = await upJyInfo(queryForm.value)
    tableData.value = res.data.info
    queryForm.value.totalSize = res.data.totalSize
  } catch (err) {
    console.log("ErrorInitInfo" + err)
    ElNotification({
      message: "请求失败~",
      type: 'error',
      duration: 1500
    })
  }
}
initInfo()
const handleDialogJyValue = (row)=> {
  if (isNull(row)) {
    dialogJyTitle.value = "新增交易数据"
    dialogJyTableValue.value = {}
  } else {
    dialogJyTitle.value = "编辑物流信息"
    dialogJyTableValue.value = JSON.parse(JSON.stringify(row))
  }
  dialogVisible.value = true
}
const handleSizeChange = (pageSize)=> {
  queryForm.value.pageSize = pageSize
  queryForm.value.pageNum = 1
  initInfo()
}
const handleCurrentChange = (pageNum)=> {
  queryForm.value.pageNum = pageNum
  initInfo()
}
const handleConfirm = async (form, formRef)=> {
  formRef.validate( async valid => {
    if (!valid) {
      console.log("errorValid")
      ElNotification({
        // message: res.msg || "请求失败~",
        message: "输入无效，请求失败~",
        type: 'error',
        duration: 1500
      })
    } else {
      try {
        let res = dialogJyTitle.value === '新增交易数据' ? await addJyInfo(form) : await editJyInfo(form)
        // console.log(res)
        if (res.status > 0) {
          //提示成功
          ElNotification({
            message: res.msg,
            type: 'success',
            duration: 1300
          })
          await initInfo()
          dialogVisible.value = false
        } else {
          ElNotification({
            message: res.msg,
            type: 'error',
            duration: 1500
          })
        }
      }catch (err) {
        console.log("errorOne: " + err)
        ElNotification({
          message: "请求失败~",
          type: 'error',
          duration: 1500
        })
      }
    }
  })
}
const delJyInfo = (row)=> {
  ElMessageBox.confirm(
      '此操作将永久删除该信息，是否继续？',
      '提示',
      {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
      }
  )
      .then(async () => {
        try {
          let res = await deleteJyInfo(row.id)
          if (res.status > 0) {
            ElMessage({
              type: 'success',
              message: '已删除',
            })
            await initInfo()
          } else {
            ElNotification({
              message: res.msg,
              type: 'error',
              duration: 1500
            })
          }
        } catch (e) {
          console.log(e)
          ElNotification({
            message: "请求失败",
            type: 'error',
            duration: 1500
          })
        }
      })
      .catch(() => {
        ElMessage({
          type: 'info',
          message: '已取消删除',
        })
      })
}*/
import Same from "../same.vue";
</script>

<style scoped>
/*.header {
  padding-bottom: 16px;
  box-sizing: border-box;
}*/
</style>